const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/playground', {useUnifiedTopology: true, useNewUrlParser: true})
    .then(()=>console.log('数据库连接成功'))
    .catch(err => console.log('数据库连接失败',err))
const courseSchema = mongoose.Schema({
    name: String,
    author: String,
    isPublished: Boolean
});
const Course = mongoose.model('Course',courseSchema);
/*Course.find({name: 'node.js'}).then(result => console.log(result))
Course.findOne().then(result => console.log(result))*/
Course.find().select('name author').then(result => console.log(result))